using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Shapes;

using SvnCore;

namespace SVNTreeViewer.VisualTreeBuilder
{
    public class BranchContainer
    {
        public BranchContainer(Branch branch)
        {
            this.Branch = branch;
        }

        public Branch Branch { get; private set; }

        public Grid CreateBranch()
        {
            Grid branchContainer = new Grid();
            branchContainer.Tag = Branch;
            branchContainer.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(30) });
            branchContainer.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Star) });
            branchContainer.Margin = new Thickness(0, 0, 0, 100);
            //// branchContainer.ContextMenu = this.CreateContextMenu();

            TextBlock label = new TextBlock
                {
                    Text = this.Branch.Uri.AbsolutePath,
                    VerticalAlignment = VerticalAlignment.Center,
                    FontSize = 14,
                    Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FFD1D1D1"))
                };

            Rectangle bar = new Rectangle
                {
                    Height = 5, 
                    Fill = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#8ED1D1D1"))
                };

            Grid barContainer = new Grid();
            barContainer.Children.Add(bar);
            barContainer.Name = "barContainer";

            Grid.SetRow(label, 0);
            Grid.SetRow(barContainer, 1);

            branchContainer.Children.Add(label);
            branchContainer.Children.Add(barContainer);
            return branchContainer;
        }
    }
}